
$(function () {
  // 设置加载隐藏
  $(".container-fluid").hide()
  // 获取轮播图
  function getBanner() {
    $.ajax({
      method: 'GET',
      url: adminPath + '/api/wdsxh/banner/index',
      headers: {
        page: 2
      },
      success: function (res) {
        $(".container-fluid").show()
        if (res.code == 1) {
          var indicatorsHtml = ""
          var innerHtml = ""
          for (var i in res.data) {
            indicatorsHtml += `<li data-target="#carouselExampleIndicators" data-slide-to="${i}" ${i == 0 ? 'class="active"' : ''}></li>`
            innerHtml += `
            <div class="carousel-item ${i == 0 ? 'active' : ''}">
              <img src="${res.data[i].pc_image}" class="w-100 normal">
              <img src="${res.data[i].image}" class="w-100 mobile">
            </div>
          `
          }
          $("#carouselExampleIndicators .carousel-indicators").html(indicatorsHtml)
          $("#carouselExampleIndicators .carousel-inner").html(innerHtml)
        } else {
          console.error(res.msg)
        }
      },
    })
  }
  // 调用方法
  getBanner()
})